package numberslider;

import javax.swing.table.AbstractTableModel;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: Dec 23, 2009
 * Time: 12:34:19 AM
 * To change this template use File | Settings | File Templates.
 */
public class ResultSetTableModel extends AbstractTableModel {

    public ResultSetTableModel(ResultSet aResultSet) {
        rs = aResultSet;
        try {
            rsmd = rs.getMetaData();
        }
        catch (SQLException e) {
            System.out.println("Error " + e);
        }
    }

    public String getColumnName(int c) {
        try {
            return rsmd.getColumnName(c + 1);
        }
        catch (SQLException e) {
            System.out.println("Error " + e);
            return "";
        }
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return null;
    }

    @Override
    public int getRowCount() {
        return 0;
    }

    public int getColumnCount() {
        try {
            return rsmd.getColumnCount();
        }
        catch (SQLException e) {
            System.out.println("Error " + e);
            return 0;
        }
    }

    protected ResultSet getResultSet() {
        return rs;
    }

    private ResultSet rs;
    private ResultSetMetaData rsmd;

}
